package com.sz.controller;

import com.sz.mapper.UserMapper;
import com.sz.model.BankCard;
import com.sz.model.Result;
import com.sz.model.TUser;
import com.sz.service.IUserInfoService;
import com.sz.service.IUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/user")
//@CrossOrigin(origins = "*",maxAge = 3600)
public class UserInfoController {

    @Autowired
    private IUserInfoService iUserInfoService;

    //通过id查询用户数据
    @RequestMapping("/queryById")
    public TUser queryById(String ukPhone) {
        return iUserInfoService.queryById(iUserInfoService.queryUserId(ukPhone));
    }

    //通过用户名查询用户银行卡信息
    @RequestMapping("/queryBank")
    public Result queryBank(String ukPhone) {
        Result result=null;
        System.out.println("----"+ukPhone);

        Long aLong = iUserInfoService.queryUserId(ukPhone);
        TUser tUser = iUserInfoService.queryById(aLong);
        BankCard bankCard = iUserInfoService.queryBankInfo(tUser.getUkIdentityId());


        List<BankCard> bankList = iUserInfoService.getBankList(aLong);
        result=new Result(200,"查询成功",bankList);


        return result;

    }
}
